<!--设置模块唯一ID-->
<div id="syjd_fayalvguanli">
    <!--标题、面包屑-->
    <section class="content-header">
        <h1>
            发芽率管理
            <small>顺义基地</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li>顺义基地</li>
            <li class="active">发芽率管理</li>
        </ol>
    </section>
    <!--列表-->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <div class="btn-group pull-left" data-type="actionBar">
                            <button type="button" class="btn btn-default" data-action="add">导入发芽率表</button>
                            <button type="button" class="btn btn-default" data-action="add1">导入绿植库</button>
                        </div>
                        <div class=" pull-right" data-type="columnControl">
                        </div>
                        <div class=" pull-right " data-type="searchControl">
                        </div>
                        <div class="clearfix"></div>
                    </div>
                    <div class="box-body">
                        <table class="table table-bordered table-striped table-hover" style="width: 2500px"></table>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <script type="text/template" data-for="tp_editor">
        <form role="form" class="form-horizontal">
            <div class="box-body">
                <div class="form-group">
                    <label class="col-sm-2 control-label">导入时间</label>

                    <div class="col-sm-10">
                        <input type="text" class="form-control" name="p1" value="<%=data.p1?data.p1:''%>" disabled>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">选择文件</label>
                    <div class="col-sm-10">
                        <input type="file" class="form-control" name="p1" value="<%=data.p1?data.p1:''%>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">进度</label>
                    <div class="col-sm-10">
                        <div class=" progress">
                            <div class="progress-bar progress-bar-primary progress-bar-striped" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: 40%">
                                <span class="sr-only">40% Complete (success)</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </script>

    <script type="text/template" data-for="tp_editor1">
        <form role="form" class="form-horizontal">
            <div class="box-body">
                <div class="form-group">
                    <label class="col-sm-2 control-label">操作人</label>

                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p1" value="<%=data.p1?data.p1:''%>" disabled>
                    </div>
                    <label class="col-sm-2 control-label">当前时间</label>

                    <div class="col-sm-4">
                        <input type="text" class="form-control" name="p1" value="<%=data.p1?data.p1:''%>" disabled>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-2"></div>
                    <div class="col-sm-10">
                        <table class="table table-bordered table-striped table-hover">
                            <thead>
                                <th>品种</th>
                                <th>系列</th>
                                <th>颜色</th>
                                <th>数量</th>
                                <th>单位</th>
                            </thead>
                            <tbody>
                                <td>1</td>
                                <td>1</td>
                                <td>1</td>
                                <td>1</td>
                                <td>1</td>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">备注</label>
                    <div class="col-sm-10">
                        <textarea class="form-control" name="p1">
                            <%=data.p1?data.p1:''%>
                        </textarea>
                    </div>
                </div>
            </div>
        </form>
    </script>

    <script>
        USEN(function () {
            //模块ID(全系统唯一)
            var id = "#syjd_fayalvguanli";

            //定义页面变量
            var $el = $(id);
            var $actionBar = $el.find("[data-type=actionBar]");
            var tableId = id + " table.table";
            var $table = $(tableId);
            var $editor = $el.find("[data-for=tp_editor]");
            var $editor1 = $el.find("[data-for=tp_editor1]");
            var myTable;


            //定义增\删\改 方法
            var editor = {
                add : function(){
                    USEN.modal({
                        title:"导入",
                        submitTxt:"确定",
                        submitCb:function($el){
                            //提交表单
                            $el.find("form").ajaxSubmit({
                                url: './simdata/common_add_action.json',
                                beforeSubmit: function (data) {
//                console.log("数据提交之前.")
                                },
                                success: function (data, state, obj) {
                                    USEN.notifyAlert({
                                        title:"提示:",
                                        content:'提交成功,刷新Table组件'
                                    });
                                    $el.modal("hide");
                                    if (myTable) myTable.ajax.reload();
                                }
                            })
                        },
                        filter:function(data){
                            return _.template($editor.html())({
                                data:data
                            });
                        }
                    });
                },
                add1 : function(){
                    USEN.modal({
                        title:"导入",
                        submitTxt:"确定",
                        submitCb:function($el){
                            //提交表单
                            $el.find("form").ajaxSubmit({
                                url: './simdata/common_add_action.json',
                                beforeSubmit: function (data) {
//                console.log("数据提交之前.")
                                },
                                success: function (data, state, obj) {
                                    USEN.notifyAlert({
                                        title:"提示:",
                                        content:'提交成功,刷新Table组件'
                                    });
                                    $el.modal("hide");
                                    if (myTable) myTable.ajax.reload();
                                }
                            })
                        },
                        filter:function(data){
                            return _.template($editor1.html())({
                                data:data
                            });
                        }
                    });
                }
            };


            // 绑定列表编辑按钮事件
            $actionBar.find("[data-action]").on("click", function () {
                var action = $(this).data("action");
                var $selected = $table.find('tr.selected');
                switch (action) {
                    case "add" :
                        editor.add();
                        break;
                    case "add1" :
                        editor.add1();
                        break;
                }
            });

            //初始化datatable数据列表
            myTable = new USEN.Datatable({
                //设置ID
                "id": tableId,
                //设置列控制模块容器
                "columnControl": id + " [data-type=columnControl]",
                //设置搜索模块容器
                "searchControl": id + " [data-type=searchControl]",
                //配置服务
                "ajax": "./simdata/common_table_ation.json",
                //列设置
                "columns": [
                    {
                        data: null,
                        defaultContent: '',
                        className: 'select-checkbox',
                        orderable: false, searchable: false,
                        width: "30px"
                    },
                    { "title": "序号", "data": "p1"},
                    { "title": "品种名称", "data": "p2"},
                    { "title": "系列", "data": "p3"},
                    { "title": "播种时间", "data": "p4" },
                    { "title": "颜色", "data": "p5" },
                    { "title": "数量", "data": "p6" },
                    { "title": "出苗量", "data": "p7" },
                    { "title": "发芽率", "data": "p8" },
                    { "title": "负责人", "data": "p9" },
                    { "title": "备注", "data": "p10" }
                ]
            })
        });
    </script>
</div>